﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinRT.Triggers.Test
{
    [TestClass]
    public class ValueComparisonTests
    {
        [TestMethod]
        public void EqualsComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.Equals, "Test"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.Equals, 123));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.Equals, 999.2F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.Equals, 8.8D));
            Assert.IsTrue(ValueComparer.Compare(true, ConditionOperator.Equals, true));
            Assert.IsTrue(ValueComparer.Compare(false, ConditionOperator.Equals, false));
            Assert.IsTrue(ValueComparer.Compare("True", ConditionOperator.Equals, true));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.Equals, false));
        }

        [TestMethod]
        public void EqualsComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.Equals, "No"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.Equals, 24));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.Equals, 99.2F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.Equals, 8.6D));
            Assert.IsFalse(ValueComparer.Compare(true, ConditionOperator.Equals, false));
            Assert.IsFalse(ValueComparer.Compare(false, ConditionOperator.Equals, true));
            Assert.IsFalse(ValueComparer.Compare("True", ConditionOperator.Equals, false));
            Assert.IsFalse(ValueComparer.Compare("False", ConditionOperator.Equals, true));
        }

        [TestMethod]
        public void NotEqualsComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.NotEquals, "No"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.NotEquals, 24));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.NotEquals, 99.2F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.NotEquals, 8.6D));
            Assert.IsTrue(ValueComparer.Compare(true, ConditionOperator.NotEquals, false));
            Assert.IsTrue(ValueComparer.Compare(false, ConditionOperator.NotEquals, true));
            Assert.IsTrue(ValueComparer.Compare("True", ConditionOperator.NotEquals, false));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.NotEquals, true));
        }

        [TestMethod]
        public void NotEqualsComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.NotEquals, "Test"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.NotEquals, 123));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.NotEquals, 999.2F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.NotEquals, 8.8D));
            Assert.IsFalse(ValueComparer.Compare(true, ConditionOperator.NotEquals, true));
            Assert.IsFalse(ValueComparer.Compare(false, ConditionOperator.NotEquals, false));
            Assert.IsFalse(ValueComparer.Compare("True", ConditionOperator.NotEquals, true));
            Assert.IsFalse(ValueComparer.Compare("False", ConditionOperator.NotEquals, false));
        }

        [TestMethod]
        public void GreaterThanComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.GreaterThan, "AAA"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.GreaterThan, 122));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.GreaterThan, 999.1F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.GreaterThan, 8.6D));
            Assert.IsTrue(ValueComparer.Compare(true, ConditionOperator.GreaterThan, false));
            Assert.IsTrue(ValueComparer.Compare("True", ConditionOperator.GreaterThan, false));
        }

        [TestMethod]
        public void GreaterThanComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.GreaterThan, "Test"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.GreaterThan, 123));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.GreaterThan, 999.2F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.GreaterThan, 8.8D));
            Assert.IsFalse(ValueComparer.Compare(false, ConditionOperator.GreaterThan, true));
            Assert.IsFalse(ValueComparer.Compare("False", ConditionOperator.GreaterThan, true));
            Assert.IsFalse(ValueComparer.Compare("True", ConditionOperator.GreaterThan, true));
        }

        [TestMethod]
        public void LessThanComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.LessThan, "Zoo"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.LessThan, 124));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.LessThan, 999.3F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.LessThan, 8.9D));
            Assert.IsTrue(ValueComparer.Compare(false, ConditionOperator.LessThan, true));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.LessThan, true));
        }

        [TestMethod]
        public void LessThanComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.LessThan, "Apple"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.LessThan, 122));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.LessThan, 123));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.LessThan, 999.1F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.LessThan, 8.2D));
            Assert.IsFalse(ValueComparer.Compare(true, ConditionOperator.LessThan, false));
            Assert.IsFalse(ValueComparer.Compare("True", ConditionOperator.LessThan, true));
        }

        [TestMethod]
        public void LessThanOrEqualComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.LessThanOrEqual, "Test"));
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.LessThanOrEqual, "Zoo"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.LessThanOrEqual, 124));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.LessThanOrEqual, 123));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.LessThanOrEqual, 999.2F));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.LessThanOrEqual, 999.3F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.LessThanOrEqual, 8.8D));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.LessThanOrEqual, 8.9D));
            Assert.IsTrue(ValueComparer.Compare(false, ConditionOperator.LessThanOrEqual, true));
            Assert.IsTrue(ValueComparer.Compare(false, ConditionOperator.LessThanOrEqual, false));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.LessThanOrEqual, true));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.LessThanOrEqual, false));
        }

        [TestMethod]
        public void LessThanOrEqualComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.LessThanOrEqual, "Apple"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.LessThanOrEqual, 122));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.LessThanOrEqual, 999.1F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.LessThanOrEqual, 8.2D));
            Assert.IsFalse(ValueComparer.Compare(true, ConditionOperator.LessThanOrEqual, false));
        }

        [TestMethod]
        public void GreaterThanOrEqualComparisonSuccessTests()
        {
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.GreaterThanOrEqual, "Test"));
            Assert.IsTrue(ValueComparer.Compare("Test", ConditionOperator.GreaterThanOrEqual, "Apple"));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.GreaterThanOrEqual, 122));
            Assert.IsTrue(ValueComparer.Compare(123, ConditionOperator.GreaterThanOrEqual, 123));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.GreaterThanOrEqual, 999.2F));
            Assert.IsTrue(ValueComparer.Compare(999.2F, ConditionOperator.GreaterThanOrEqual, 999.1F));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.GreaterThanOrEqual, 8.8D));
            Assert.IsTrue(ValueComparer.Compare(8.8D, ConditionOperator.GreaterThanOrEqual, 8.7D));
            Assert.IsTrue(ValueComparer.Compare(true, ConditionOperator.GreaterThanOrEqual, true));
            Assert.IsTrue(ValueComparer.Compare(true, ConditionOperator.GreaterThanOrEqual, false));
            Assert.IsTrue(ValueComparer.Compare("True", ConditionOperator.GreaterThanOrEqual, true));
            Assert.IsTrue(ValueComparer.Compare("False", ConditionOperator.GreaterThanOrEqual, false));
        }

        [TestMethod]
        public void GreaterThanOrEqualComparisonFailureTests()
        {
            Assert.IsFalse(ValueComparer.Compare("Test", ConditionOperator.GreaterThanOrEqual, "Zoo"));
            Assert.IsFalse(ValueComparer.Compare(123, ConditionOperator.GreaterThanOrEqual, 124));
            Assert.IsFalse(ValueComparer.Compare(999.2F, ConditionOperator.GreaterThanOrEqual, 999.4F));
            Assert.IsFalse(ValueComparer.Compare(8.8D, ConditionOperator.GreaterThanOrEqual, 8.9D));
            Assert.IsFalse(ValueComparer.Compare(false, ConditionOperator.GreaterThanOrEqual, true));
        }
    }
}
